//===== eAthena Script =======================================
//= ĤG𫰾
//===== By: ==================================================
//= L0ne_W0lf
//===== Current Version: =====================================
//= 1.9
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
//= WoE SE cǨ а Castle 1 (ǧ)
//============================================================

arug_cas01,1,1,0	script	Manager#aru01_02	111,{
	end;

OnInterIfInitOnce:
	GetCastleData "arug_cas01",0,"::OnRecvCastleAr01";
	end;

OnRecvCastleAr01:
	RequestGuildInfo GetCastleData("arug_cas01",1);
	if (GetCastleData("arug_cas01",1) == 0) {
		donpcevent "Manager#aru01_02::Onstart";
	}
	end;

OnAgitStart2:
	if (agitcheck2()) {
		MapRespawnGuildID "arug_cas01",GetCastleData("arug_cas01",1),2;
		GvgOn "arug_cas01";
		donpcevent "Manager#aru01_02::Onstart";
	}
	else {
		donpcevent "#aru01_RL00::OnDisable";
		donpcevent "#aru01_RL01::OnDisable";
		donpcevent "#aru01_RL02::OnDisable";
		donpcevent "#aru01_RL03::OnDisable";
	}
	end;

OnAgitEnd2:
	GvgOff "arug_cas01";
	if (GetCastleData("arug_cas01",1)) {
		KillMonster "arug_cas01","޲zH#aru01::OnStartArena";
		donpcevent "Manager#aru01_02::Onreset";
		donpcevent "޲zH#aru01::Onstop";
	}
	end;

Onstart:
	// 1st Guardian stone, 2nd Guardian stone, Barrier 1, Barrier 2, Barrier 3, Summon Guardians
	// Settings for all but Summon Guardians
	// 0 = Okay; 1 = Destroyed; 2 = Repairing
	// Summon Guardians
	// 0 = Do not Summon; 1 = Summon
	if (GetCastleData("arug_cas01",1)) {
		setarray $agit_ar01[0],0,0,0,0,0,0;
		donpcevent "#aru01_df01::OnEnable";
		donpcevent "#aru01_df02::OnEnable";
		donpcevent "#aru01_RL00::OnEnable";
		donpcevent "#aru01_RL01::OnEnable";
		donpcevent "#aru01_RL02::OnEnable";
		donpcevent "#aru01_RL03::OnEnable";
	}
	monster "arug_cas01",87,219,"R",1288,1,"޲zH#aru01::OnStartArena";
	end;

Onreset:
	donpcevent "#aru01_df01::OnDisable";
	donpcevent "#aru01_df02::OnDisable";
	donpcevent "#aru01_gard01::Onreset";
	donpcevent "#aru01_gard02::Onreset";
	donpcevent "#aru01_RL00::OnDisable";
	donpcevent "#aru01_RL01::OnDisable";
	donpcevent "#aru01_RL02::OnDisable";
	donpcevent "#aru01_RL03::OnDisable";
	donpcevent "1u@#aru01::OnDisable";
	donpcevent "2u@#aru01::OnDisable";
	donpcevent "˸m01#aru01::OnDisable";
	donpcevent "˸m02#aru01::OnDisable";
	donpcevent "˸m03#aru01::OnDisable";
	if (agitcheck2()) {
		setarray $agit_ar01[0],0,0,1,1,1,0;
	}
	end;

Onchange:
	setarray $agit_ar01[0],2,2,1,1,2,0;
	monster "arug_cas01",87,219,"R",1288,1,"޲zH#aru01::OnStartArena";
	donpcevent "˸m03#aru01::OnEnable";
	donpcevent "1u@#aru01::OnEnable";
	donpcevent "2u@#aru01::OnEnable";
	end;

OnClock0001:
	if (!GetCastleData("arug_cas01",1)) end;
	killmonster "arug_cas01","Manager#aru01_02::OnTreasureDied";

	if (GetCastleData("arug_cas01",4)) {
		set .@Economy,GetCastleData("arug_cas01",2);
		SetCastleData "arug_cas01",2,.@Economy + GetCastleData("arug_cas01",4) + (rand(2) && getgdskilllv(.@GID,10014));
		if (GetCastleData("arug_cas01",2) > 100) SetCastleData "arug_cas01",2,100;
		setcastledata "arug_cas01",4,0;
	}
	if (GetCastleData("arug_cas01",5)) {
		set .@Defence,GetCastleData("arug_cas01",3);
		SetCastleData "arug_cas01",3,.@Defence + GetCastleData("arug_cas01",5);
		if (GetCastleData("arug_cas01",3) > 100) SetCastleData "arug_cas01",3,100;
		setcastledata "arug_cas01",5,0;
	}

	set .@Treasure,GetCastleData("arug_cas01",2)/5+4;
	if (.@Treasure) {
		monster "arug_cas01",251,369,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		monster "arug_cas01",251,369,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		monster "arug_cas01",253,369,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		monster "arug_cas01",254,369,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 5) end;
		monster "arug_cas01",255,368,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 6) end;
		monster "arug_cas01",256,368,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 7) end;
		monster "arug_cas01",257,368,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 8) end;
		monster "arug_cas01",258,368,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 9) end;
		monster "arug_cas01",251,367,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 10) end;
		monster "arug_cas01",252,367,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 11) end;
		monster "arug_cas01",253,367,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 12) end;
		monster "arug_cas01",254,367,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 13) end;
		monster "arug_cas01",255,366,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 14) end;
		monster "arug_cas01",256,366,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 15) end;
		monster "arug_cas01",257,366,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 16) end;
		monster "arug_cas01",258,366,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 17) end;
		monster "arug_cas01",251,365,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 18) end;
		monster "arug_cas01",252,365,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 19) end;
		monster "arug_cas01",253,365,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 20) end;
		monster "arug_cas01",254,365,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 21) end;
		monster "arug_cas01",255,364,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 22) end;
		monster "arug_cas01",256,364,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 23) end;
		monster "arug_cas01",257,364,"_cl",1943,1,"Manager#aru01_02::OnTreasureDied";
		if (.@Treasure < 24) end;
		monster "arug_cas01",258,364,"_cl",1324,1,"Manager#aru01_02::OnTreasureDied";
	}
	end;

OnTreasureDied:
	end;
}

arug_cas01,112,193,1	script	p̴#aru01_01	868,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (.@GID == 0) {
		mes "[p̴]";
		mes "\H?";
		mes "ЧA֤@I}oya!";
		close;
	}
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) != getguildmaster(.@GID)) {
			mes "[p̴]";
			mes "ڬOtdu@,";
			mes "ԲӪeڷQDH";
			close;
		}
		else {
			if (agitcheck2() == 0) {
				mes "[p̴]";
				mes "I am Brace, guardian of";
				mes "this stronghold. For now,";
				mes "all is quiet in this place.";
				next;
				switch(select("Converse:")) {
				case 1:
					mes "[p̴]";
					mes "Do you have any questions";
					mes "about this stronghold?";
					next;
					switch(select("u@:mu:Ŷʨt:Battle Strategy:")) {
					case 1:
						mes "[p̴]";
						mes "There is one Emperium";
						mes "and two Guardian Stones in";
						mes "each fortress. These stones";
						mes "are the first line of defense,";
						mes "and must be destroyed before";
						mes "enemies can even enter.";
						next;
						mes "[p̴]";
						mes "The stones are located in";
						mes "^4D4DFFGate Houses^000000 which must be";
						mes "protected to prevent enemies";
						mes "from reaching the Emperium.";
						mes "Guardian Stones can ^4D4DFFrecall";
						mes "your Guardians^000000 for protection.";
						next;
						mes "[p̴]";
						mes "Fortresses with higher levels";
						mes "of defense can summon more";
						mes "Guardians: this is why it is";
						mes "so important for guilds to";
						mes "invest in Defense Growth.";
						next;
						mes "[p̴]";
						mes "Guardian Stones that have";
						mes "been destroyed can be revived";
						mes "after a certain time, but one of^FFFFFF ^000000 the guild members must give";
						mes "me the order. I can also report^FFFFFF ^000000 the status of the Guardian Stones.";
						close;
					case 2:
						mes "[p̴]";
						mes "^4D4DFFFortress Gates^000000 are the second ^FFFFFF ^000000 line of guild stronghold defense,";
						mes "and are protected by extra barricades activated by the Guardian Stones.";
						mes "These gates are located in three different parts of the fortress.";
						next;
						mes "[p̴]";
						mes "Barricades are protected by";
						mes "Guardian Stones, and are";
						mes "restored when the Guardian";
						mes "Stones are retrieved. However,";
						mes "it is not as easy to restore";
						mes "destroyed Fortress Gates.";
						next;
						mes "[p̴]";
						mes "Fortress Gates can only be";
						mes "restored when the ^4D4DFFguild";
						mes "master of a stronghold";
						mes "changes^000000, or if ^4D4DFFrestoration";
						mes "is requested by the guild";
						mes "master of the stronghold^000000.";
						close;
					case 3:
						mes "[p̴]";
						mes "Strongholds have many";
						mes "Link Flags that allow you";
						mes "to access vital areas within";
						mes "restrictions placed by the";
						mes "Barricades. Usually, ^4D4DFFFlag 1";
						mes "links to the Gate House^000000.";
						next;
						mes "[p̴]";
						mes "Many flags link directly to";
						mes "the flag near the Emperium.";
						mes "The final numbered flag is";
						mes "linked to the Convenience";
						mes "Facility of the stronghold's";
						mes "owner. Keep this in mind.";
						close;
					case 4:
						mes "[p̴]";
						mes "Strategy? It would be better";
						mes "to develop your battle plan to";
						mes "exploit your guild's advantages";
						mes "and your enemies' weaknesses.";
						mes "Use the Gate Houses and Barricades, and rebuild as quickly as you can!";
						close;
					case 5:
						mes "[p̴]";
						mes "You have no questions";
						mes "to ask of me? Well, I'm";
						mes "here to serve your needs.";
						close;
					}
				case 2:
					mes "[p̴]";
					mes "I'm always here, so";
					mes "feel free to request my";
					mes "assistance whenever";
					mes "the need arises.";
					close;
				}
			}
			else {
				mes "[p̴]";
				mes "Greetings, "+strcharinfo(0)+".";
				mes "What are your orders?";
				next;
				switch(select("Increase Stronghold Defense:ˬdmA:")) {
				case 1:
					if ($agit_ar01[5] == 0) {
						if (getgdskilllv(.@GID,10002) == 0) {
							mes "[p̴]";
							mes "I'm sorry, but the Guardian";
							mes "Stones aren't powerful enough";
							mes "to summon Guardians yet. We";
							mes "need to accumulate more";
							mes "knowledge before they can";
							mes "summon any Guardians.";
							close;
						}
						else {
							mes "[p̴]";
							mes "I shall endeavor to summon";
							mes "a Guardian through a Guardian";
							mes "Stone. However, keep in mind";
							mes "that this will not work if the";
							mes "Guardian Stone is destroyed.";
							setarray $agit_ar01[5],1;
							if ($agit_ar01[0] == 0) {
								donpcevent "#aru01_gard01::OnEnable";
							}
							if ($agit_ar01[1] == 0) {
								donpcevent "#aru01_gard02::OnEnable";
							}
							close;
						}
					}
					else {
						mes "[p̴]";
						mes "You've already commanded";
						mes "me to summon a Guardian";
						mes "to defend the stronghold.";
						close;
					}
				case 2:
					mes "[p̴]";
					mes "ڭ̪mAO...";
					if ($agit_ar01[0] == 1) {
						mes "1u@: ^FF0000Q}a^000000";
					}
					else if ($agit_ar01[0] == 2) {
						mes "1u@: ^008000״_^000000";
					}
					else {
						mes "1u@: ^4D4DFF`^000000";
					}
					if ($agit_ar01[1] == 1) {
						mes "2u@: ^FF0000Q}a^000000";
					}
					else if ($agit_ar01[1] == 2) {
						mes "2u@: ^008000״_^000000";
					}
					else {
						mes "2u@: ^4D4DFF`^000000";
					}
					if ($agit_ar01[2] == 1) {
						mes "1mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar01[2] == 2) {
						mes "1mu: ^008000״_^000000";
					}
					else {
						mes "1mu: ^4D4DFF`^000000";
					}
					if ($agit_ar01[3] == 1) {
						mes "2mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar01[3] == 2) {
						mes "2mu: ^008000״_^000000";
					}
					else {
						mes "2mu: ^4D4DFF`^000000";
					}
					if ($agit_ar01[4] == 1) {
						mes "3mu: ^FF0000Q}a^000000";
					}
					else if ($agit_ar01[4] == 2) {
						mes "3mu: ^008000״_^000000";
					}
					else {
						mes "3mu: ^4D4DFF`^000000";
					}
					close;
				case 3:
					mes "[p̴]";
					mes "Hɦb,";
					mes "Աz";
					close;
				}
			}
		}
	}
	else {
		mes "[p̴]";
		mes "\H?";
		mes "ЧA֤@I}oya!";
		close;
	}

OnInit:
	setarray $agit_ar01[0],0,0,0,0,0,0;
	end;
}

arug_cas01,1,1,0	script	#aru01_gard01	-1,{
OnEnable:
	set .@Defence,GetCastleData("arug_cas01",3);
	guardian "arug_cas01",233,83,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //0;
	if ((.@Defense > 10) && (.@Defense < 31)) {
		set .MyMobCount,2;
		guardian "arug_cas01",252,81,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //1;
	}
	else if ((.@Defense > 30) && (.@Defense < 51)) {
		set .MyMobCount,3;
		guardian "arug_cas01",252,81,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //1;
		guardian "arug_cas01",232,108,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //2;
	}
	else if ((.@Defense > 50) && (.@Defense < 71)) {
		set .MyMobCount,4;
		guardian "arug_cas01",252,81,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //1;
		guardian "arug_cas01",232,108,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //2;
		guardian "arug_cas01",201,130,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //3;
	}
	else if (.@Defense > 70) {
		set .MyMobCount,5;
		guardian "arug_cas01",252,81,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //1;
		guardian "arug_cas01",232,108,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //2;
		guardian "arug_cas01",201,130,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //3;
		guardian "arug_cas01",224,168,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //4;
	}
	else {
		set .MyMobCount,2;
		guardian "arug_cas01",195,250,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //1;
	}
	initnpctimer;
	end;

OnTimer300000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",196,137,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //5;
	mapannounce "arug_cas01","bI 1l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",269,89,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //6;
	mapannounce "arug_cas01","bI 2l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer1800000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",252,81,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //7;
	mapannounce "arug_cas01","bI 3l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer2700000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",201,130,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //8;
	mapannounce "arug_cas01","bI 4l[lX@H]F",bc_map,"0xff4500";
	end;

OnTimer3600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",224,168,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //9;
	mapannounce "arug_cas01","bI 5l[lX@H]F",bc_map,"0xff4500";
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "arug_cas01",222,129,"Ch@H]",1899,"#aru01_gard01::OnGuardianDied"; //10;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "arug_cas01","#aru01_gard01::OnGuardianDied";
	end;
}

arug_cas01,1,2,0	script	#aru01_gard02	-1,{
OnEnable:
	set .@Defence,GetCastleData("arug_cas01",3);
	guardian "arug_cas01",294,210,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //11;
	if ((.@Defense > 10) && (.@Defense < 31)) {
		set .MyMobCount,2;
		guardian "arug_cas01",256,203,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //12;
	}
	else if ((.@Defense > 30) && (.@Defense < 51)) {
		set .MyMobCount,3;
		guardian "arug_cas01",256,203,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //12;
		guardian "arug_cas01",240,133,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //13;
	}
	else if ((.@Defense > 50) && (.@Defense < 71)) {
		set .MyMobCount,4;
		guardian "arug_cas01",256,203,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //12;
		guardian "arug_cas01",240,133,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //13;
		guardian "arug_cas01",246,92,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //14;
	}
	else if (.@Defense > 70) {
		set .MyMobCount,5;
		guardian "arug_cas01",256,203,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //12;
		guardian "arug_cas01",240,133,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //13;
		guardian "arug_cas01",246,92,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //14;
		guardian "arug_cas01",235,132,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //15;
	}
	else {
		set .MyMobCount,2;
		guardian "arug_cas01",292,188,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //12;
	}
	initnpctimer;
	end;

OnTimer600000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",235,132,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //16;
	end;

OnTimer1200000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",246,92,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //17;
	end;

OnTimer2100000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",240,133,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //18;
	end;

OnTimer3000000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",256,203,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //19;
	end;

OnTimer3900000:
	set .MyMobCount,.MyMobCount+1;
	guardian "arug_cas01",254,95,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //20;
	stopnpctimer;
	end;

OnGuardianDied:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount < 2) {
		set .MyMobCount,.MyMobCount+1;
		guardian "arug_cas01",242,151,"Ch@H]",1899,"#aru01_gard02::OnGuardianDied"; //21;
	}
	end;

Onreset:
	stopnpctimer;
	killmonster "arug_cas01","#aru01_gard02::OnGuardianDied";
	end;
}

arug_cas01,1,3,0	script	#aru01_df01	-1,{
OnEnable:
	guardian "arug_cas01",210,234," 1 u@",1907,"#aru01_df01::OnGuardianDied"; //22;
	end;

OnDisable:
	killmonster "arug_cas01","#aru01_df01::OnGuardianDied";
	setarray $agit_ar01[0],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 1st Guardian Stone is Destroyed
	setarray $agit_ar01[0],1;
	if (($agit_ar01[0] == 1) || ($agit_ar01[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_ar01[1] == 1) || ($agit_ar01[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "arug_cas01","u@ۥ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru01_RL00::OnDisable";
		donpcevent "#aru01_gard01::Onreset";
	}
	else {
		mapannounce "arug_cas01","1u@ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru01_gard01::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "1u@#aru01::OnEnable";
	setarray $agit_ar01[0],2; //Global Variable
	stopnpctimer;
	end;
}

arug_cas01,211,234,0	script	1u@#aru01	844,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "}au@ۭnsΦF,";
		mes "YnsΦ pUһݤUCq";
		next;
		mes " 1,";
		mes "T 1,";
		mes "Y 30,";
		mes "Ŧ]Oq 5,";
		mes "]Oq 5,";
		mes "]Oq 5";
		next;
		mes "аݭn~򪺶i@~?";
		switch(select(":i")) {
		case 1:
			mes "Ҧ@~QF";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "n̾";
				mes "Y,T,ݪǨӰtm,";
				mes "FnsΦ";
				mes "ntm]O]Oq";
				next;
				switch(select("T::Y")) {
				case 1:
					mes "bWT";
					next;
					break;
				case 2:
					mes "bW";
					next;
					break;
				case 3:
					mes "bWY";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "tmT";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "tm";
					next;
					break;
				case 3:
					mes "tmY";
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "Tb̤W";
					next;
					break;
				case 2:
					mes "⯫ݩb̤W";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "Yb̤W";
					next;
					break;
				}
				mes "HI]k";
				mes "ntm]O]Oq,";
				mes "]OʽηǳƪĪGHKio";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_ar01[0] == 0) {
						mes "u@ۭsΦwgQF";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "]]O۪Ĭ";
							mes "u@ۭsΦѤF";
							close;
						}
						else {
							mes "wF]Oq۪tm,";
							mes "u@۪sΦO\!!!";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#aru01_df01::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "1u@#aru01";
							setarray $agit_ar01[0],0;
							set .@df_all,$agit_ar01[0]+$agit_ar01[1];
							if (.@df_all == 0) {
								mapannounce "arug_cas01","u@ۤw״_ }ljĵ٤F",bc_map,"0x00ff00";
								donpcevent "#aru01_RL00::OnEnable";
							}
							else {
								mapannounce "arug_cas01","1u@ۭsΦ w\F!",bc_map,"0x00ff00";
							}
							if ($agit_ar01[5] == 1) {
								donpcevent "#aru01_gard01::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "Ҧ@~.. ININT";
					mes "S󪺤";
					mes "ݼˤlOѪˤl,";
					mes "hF";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "ƨäOܥR";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "1u@#aru01";
	end;

OnEnable:
	enablenpc "1u@#aru01";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "1u@#aru01";
	end;
}

arug_cas01,1,4,0	script	#aru01_df02	-1,{
OnEnable:
	guardian "arug_cas01",308,189," 2 u@",1908,"#aru01_df02::OnGuardianStoneDied"; //23;
	end;

OnDisable:
	killmonster "arug_cas01","#aru01_df02::OnGuardianStoneDied";
	setarray $agit_ar01[1],1; //Global Variable
	stopnpctimer;
	end;

OnGuardianStoneDied:
	// 2nd Guardian Stone is Destroyed
	setarray $agit_ar01[1],1;
	if (($agit_ar01[0] == 1) || ($agit_ar01[0] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (($agit_ar01[1] == 1) || ($agit_ar01[1] == 2)) {
		set .@destroyed,.@destroyed + 1;
	}
	if (.@destroyed == 2) {
		mapannounce "arug_cas01","u@ۥ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru01_RL00::OnDisable";
		donpcevent "#aru01_gard02::Onreset";
	}
	else {
		mapannounce "arug_cas01","2u@ Q}aF!",bc_map,"0x00ff00";
		donpcevent "#aru01_gard02::Onreset";
	}
	initnpctimer;
	end;

OnTimer300000:
	donpcevent "2u@#aru01::OnEnable";
	setarray $agit_ar01[1],2; //Global Variable
	stopnpctimer;
	end;
}

arug_cas01,308,189,0	script	2u@#aru01	844,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "}au@ۭnsΦF,";
		mes "YnsΦ pUһݤUCq";
		next;
		mes " 1,";
		mes "T 1,";
		mes "Y 30,";
		mes "Ŧ]Oq 5,";
		mes "]Oq 5,";
		mes "]Oq 5";
		next;
		mes "аݭn~򪺶i@~?";
		switch(select(":i")) {
		case 1:
			mes "Ҧ@~QF";
			close;
		case 2:
			if ((countitem(984) > 0) && (countitem(985) > 0) && (countitem(7049) > 29) && (countitem(717) > 4) && (countitem(715) > 4) && (countitem(716) > 4)) {
				mes "n̾";
				mes "Y,T,ݪǨӰtm,";
				mes "FnsΦ";
				mes "ntm]O]Oq";
				next;
				switch(select("T::Y")) {
				case 1:
					mes "bWT";
					next;
					break;
				case 2:
					mes "bW";
					next;
					break;
				case 3:
					mes "bWY";
					set .@nice,.@nice+10;
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "tmT";
					set .@nice,.@nice+10;
					next;
					break;
				case 2:
					mes "tm";
					mes "with some Oridecon.^000000";
					next;
					break;
				case 3:
					mes "tmY";
					next;
					break;
				}
				switch(select("T::Y")) {
				case 1:
					mes "Tb̤W";
					next;
					break;
				case 2:
					mes "⯫ݩb̤W";
					set .@nice,.@nice+10;
					next;
					break;
				case 3:
					mes "Yb̤W";
					next;
					break;
				}
				mes "HI]k";
				mes "ntm]O]Oq,";
				mes "]OʽηǳƪĪGHKio";
				next;
				while(1) {
					if (.@roof0 > 7) {
						break;
					}
					else {
						switch(rand(1,3)) {
						case 1:
							specialeffect EF_BEGINSPELL2;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							}
							break;
						case 2:
							specialeffect EF_VOLCANO;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 2:
								mes "tm]OqۤF,";
								close;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
							break;
						case 3:
							specialeffect EF_BEGINSPELL4;
							mes "аtm]O@˪]k";
							mes "]Oqۧa";
							next;
							switch(select("]Oq:]Oq:Ŧ]Oq")) {
							case 1:
								mes "tm]OqۤF";
								close;
							case 2:
								mes "tm]OqۤF,";
								set .@nice,.@nice+10;
								set .@roof0,.@roof0 + 1;
								specialeffect EF_STEAL;
								next;
								break;
							case 3:
								mes "tmŦ]OqۤF,";
								close;
							}
						}
					}
				}
				if (.@nice > 90) {
					if ($agit_ar01[1] == 0) {
						mes "u@ۭsΦwgQF";
						close;
					}
					else {
						if (agitcheck2() == 0) {
							mes "]]O۪Ĭ";
							mes "u@ۭsΦѤF";
							close;
						}
						else {
							mes "wg]Oq۪tm,";
							mes "u@۪sΦO\!!!";
							delitem 984,1; //Oridecon
							delitem 985,1; //Elunium
							delitem 7049,30; //Stone
							delitem 717,5; //Blue_Gemstone
							delitem 715,5; //Yellow_Gemstone
							delitem 716,5; //Red_Gemstone
							close2;
							donpcevent "#aru01_df02::OnEnable";
							specialeffect EF_ICECRASH;
							disablenpc "2u@#aru01";
							setarray $agit_ar01[1],0;
							set .@df_all,$agit_ar01[0]+$agit_ar01[1];
							if (.@df_all == 0) {
								mapannounce "arug_cas01","u@ۤw״_ }ljĵ٤F",bc_map,"0x00ff00";
								donpcevent "#aru01_RL00::OnEnable";
							}
							else {
								mapannounce "arug_cas01","2u@ۭsΦ w\F!",bc_map,"0x00ff00";
							}
							if ($agit_ar01[5] == 1) {
								donpcevent "#aru01_gard02::OnEnable";
							}
							end;
						}
					}
				}
				else {
					mes "Ҧ@~.. ININT";
					mes "S󪺤";
					mes "ݼˤlOѪˤl,";
					mes "hF";
					delitem 7049,10; //Stone
					delitem 717,2; //Blue_Gemstone
					delitem 715,2; //Yellow_Gemstone
					delitem 716,2; //Red_Gemstone
					close;
				}
			}
			else {
				mes "ƨäOܥR";
				close;
			}
		}
	}
	end;

OnInit:
	disablenpc "2u@#aru01";
	end;

OnEnable:
	enablenpc "2u@#aru01";
	specialeffect EF_MAPPILLAR2;
	end;

OnDisable:
	disablenpc "2u@#aru01";
	end;
}

arug_cas01,2,1,0	script	#aru01_RL00	-1,{
OnEnable:
	setwall "arug_cas01",238,74,8,6,0,"aru01_RL00";
	guardian "arug_cas01",239,73," ",1905,"#aru01_RL00::OnBarrierDestroyed"; //24;
	guardian "arug_cas01",241,73," ",1905,"#aru01_RL00::OnBarrierDestroyed"; //25;
	guardian "arug_cas01",243,73," ",1905,"#aru01_RL00::OnBarrierDestroyed"; //26;
	guardian "arug_cas01",245,73," ",1905,"#aru01_RL00::OnBarrierDestroyed"; //27;
	end;

OnDisable:
	delwall "aru01_RL00";
	killmonster "arug_cas01","#aru01_RL00::OnBarrierDestroyed";
	end;

OnBarrierDestroyed:
	end;
}

arug_cas01,2,2,0	script	#aru01_RL01	-1,{
OnEnable:
	set .MyMobCount,6;
	setwall "arug_cas01",239,53,8,6,1,"aru01_RL01";
	guardian "arug_cas01",239,55," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //28;
	guardian "arug_cas01",241,55," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //29;
	guardian "arug_cas01",243,55," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //30;
	guardian "arug_cas01",240,54," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //31;
	guardian "arug_cas01",242,54," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //32;
	guardian "arug_cas01",244,54," ",1905,"#aru01_RL01::OnBarrierDestroyed"; //33;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar01[2],1;
		mapannounce "arug_cas01","1mu Q}F",bc_map,"0x00ff00";
		delwall "aru01_RL01";
	}
	end;

OnDisable:
	delwall "aru01_RL01";
	killmonster "arug_cas01","#aru01_RL01::OnBarrierDestroyed";
	end;
}

arug_cas01,2,3,0	script	#aru01_RL02	-1,{
OnEnable:
	set .MyMobCount,6;
	setwall "arug_cas01",107,124,6,6,1,"aru01_RL02";
	guardian "arug_cas01",107,122," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //34;
	guardian "arug_cas01",109,122," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //35;
	guardian "arug_cas01",111,122," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //36;
	guardian "arug_cas01",108,123," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //37;
	guardian "arug_cas01",110,123," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //38;
	guardian "arug_cas01",112,123," ",1905,"#aru01_RL02::OnBarrierDestroyed"; //39;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar01[3],1;
		mapannounce "arug_cas01","2mu Q}F",bc_map,"0x00ff00";
		delwall "aru01_RL02";
	}
	end;

OnDisable:
	delwall "aru01_RL02";
	killmonster "arug_cas01","#aru01_RL02::OnBarrierDestroyed";
	end;
}

arug_cas01,2,4,0	script	#aru01_RL03	-1,{
OnEnable:
	set .MyMobCount,4;
	setwall "arug_cas01",84,171,8,6,1,"aru01_RL03";
	guardian "arug_cas01",84,170," ",1905,"#aru01_RL03::OnBarrierDestroyed"; //40;
	guardian "arug_cas01",86,170," ",1905,"#aru01_RL03::OnBarrierDestroyed"; //41;
	guardian "arug_cas01",88,170," ",1905,"#aru01_RL03::OnBarrierDestroyed"; //42;
	guardian "arug_cas01",90,170," ",1905,"#aru01_RL03::OnBarrierDestroyed"; //43;
	end;

OnBarrierDestroyed:
	set .MyMobCount,.MyMobCount-1;
	if (.MyMobCount == 0) {
		setarray $agit_ar01[4],1;
		mapannounce "arug_cas01","3mu Q}F!!",bc_map,"0x00ff00";
		delwall "aru01_RL03";
	}
	end;

OnDisable:
	delwall "aru01_RL03";
	killmonster "arug_cas01","#aru01_RL03::OnBarrierDestroyed";
	end;
}

arug_cas01,247,52,0	script	˸m01#aru01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar01[2] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon,";
									mes "but it's not working very well.^FFFFFF ^3355FF You'll have to try something else.";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru01_RL01::OnEnable";
							disablenpc "˸m01#aru01";
							mapannounce "arug_cas01"," 1 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar01[2],0;
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m01#aru01";
	end;

OnEnable:
	enablenpc "˸m01#aru01";
	end;

OnDisable:
	disablenpc "˸m01#aru01";
	end;
}

arug_cas01,118,131,0	script	˸m02#aru01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar01[3] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru01_RL02::OnEnable";
							disablenpc "˸m02#aru01";
							mapannounce "arug_cas01"," 2 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar01[3],0; //Global Variable
							setarray $agit_ar01[2],2; //Global Variable
							donpcevent "˸m01#aru01::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m02#aru01";
	end;

OnEnable:
	enablenpc "˸m02#aru01";
	end;

OnDisable:
	disablenpc "˸m02#aru01";
	end;
}

arug_cas01,82,172,0	script	˸m03#aru01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		if (strcharinfo(0) == getguildmaster(.@GID)) {
			if ($agit_ar01[4] == 2) {
				mes "^3355FFDemolished Fortress";
				mes "Gates can be repaired,";
				mes "but you will need to gather";
				mes "the following materials.^000000";
				next;
				mes "K 10,";
				mes "K 30,";
				mes "jƪZ-żƤG 5,";
				mes " 10";
				next;
				select("Continue");
				if ((countitem(1019) > 29) && (countitem(999) > 9) && (countitem(1011) > 9) && (countitem(984) > 4)) {
					mes "^3355FFYou will need Trunks to";
					mes "repair the support frame,";
					mes "Oridecon to enhance the";
					mes "gate's endurance, and";
					mes "Emveretarcon to basically";
					mes "hold everything together.^000000";
					next;
					set .@ro_of01,rand(10,15);
					while(1) {
						if (.@ro_of02 == .@ro_of01) {
							break;
						}
						else {
							switch(rand(1,4)) {
							case 1:
								mes "^3355FFThe support frame";
								mes "is badly damaged:";
								mes "fixing this part";
								mes "is a top priority.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFThe frame has been";
									mes "reinforced with wood.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 2:
								mes "^3355FFIt looks like the gate's";
								mes "overall endurance needs to";
								mes "be reinforced with something.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood";
									mes "to reinforce the gate.^000000";
									set .@ro_of02,.@ro_of02 + 1;
									next;
									break;
								case 2:
									mes "^3355FFYou tried using steel";
									mes "to reinforce the gate, but";
									mes "it's not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou hammered the";
									mes "oridecon: it looks";
									mes "like this will work.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								}
								break;
							case 3:
								mes "^3355FFThe damage to the gate";
								mes "has caused all these";
								mes "cracks. You'll have to";
								mes "weld them solid somehow.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou used steel to weld";
									mes "all the cracks: the gate is";
									mes "is starting to look more solid.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 3:
									mes "^3355FFYou tried using emveretarcon";
									mes "to reinforce the gate, but it's";
									mes "not working well at all.";
									mes "You'll have to start over.^000000";
									close;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
								break;
							case 4:
								mes "^3355FFNow you need to make";
								mes "sure that the gate is held";
								mes "together pretty solidly.^000000";
								next;
								switch(select("K:K:jƪZ-żƤG:")) {
								case 1:
									mes "^3355FFYou tried using wood to fix";
									mes "this problem, but it seems";
									mes "to have made it worse.";
									mes "You'll have to start all over.^000000";
									close;
								case 2:
									mes "^3355FFYou tried using steel,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								case 3:
									mes "^3355FFYou successfully used";
									mes "the emveretarcon to repair";
									mes "much of the gate's damage.^000000";
									set .@rp_temp,.@rp_temp + 1;
									set .@ro_of02,.@ro_of02 + 1;
									specialeffect2 EF_REPAIRWEAPON;
									next;
									break;
								case 4:
									mes "^3355FFYou tried using oridecon,";
									mes "but it's not working very";
									mes "well. You'll have to try";
									mes "something else.^000000";
									close;
								}
							}
						}
					}
					mes "^3355FFWell, it looks like";
					mes "you're just about done";
					mes "with repairing the gate.^000000";
					next;
					if (agitcheck2() == 0) {
						mes "^3355FFUnfortunately, the Fortress";
						mes "Gate can't be reconstructed:";
						mes "the Emperium is no longer here.^000000";
						close;
					}
					else {
						if (.@rp_temp == .@ro_of01) {
							mes "^3355FFThe Fortress Gate has";
							mes "been successfully repaired!^000000";
							delitem 1019,30; //Wooden_Block
							delitem 999,10; //Steel
							delitem 1011,10; //Emveretarcon
							delitem 984,5; //Oridecon
							close2;
							donpcevent "#aru01_RL03::OnEnable";
							disablenpc "˸m03#aru01";
							mapannounce "arug_cas01"," 3 mu sظm\F!",bc_map,"0x00ff00";
							setarray $agit_ar01[4],0;
							setarray $agit_ar01[3],2;
							donpcevent "˸m02#aru01::OnEnable";
							end;
						}
						else {
							mes "^3355FFThe wall has been breached,";
							mes "and the attempt to repair the";
							mes "Fortress Gate has failed.";
							mes "You lost some of your";
							mes "repair resources...^000000";
							delitem 984,2; //Oridecon
							delitem 999,4; //Steel
							delitem 1019,14; //Wooden_Block
							delitem 1011,3; //Emveretarcon
							close;
						}
					}
				}
				else {
					mes "^3355FFYou can't attempt to repair";
					mes "the Fortress Gate if you don't";
					mes "have all the needed materials.^000000";
					close;
				}
			}
		}
	}
	end;

OnInit:
	disablenpc "˸m03#aru01";
	end;

OnEnable:
	enablenpc "˸m03#aru01";
	end;

OnDisable:
	disablenpc "˸m03#aru01";
	end;
}

// Link Flags
arug_cas01,74,232,0	script	LF-01#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select(" 1 I: 2 I:")) {
		case 1:
			warp "arug_cas01",158,237;
			end;
		case 2:
			warp "arug_cas01",297,248;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,77,232,0	script	LF-02#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 1-1:ma 1-2:")) {
		case 1:
			warp "arug_cas01",197,144;
			end;
		case 2:
			warp "arug_cas01",245,103;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,80,232,0	script	LF-03#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 2-1:ma 2-2:")) {
		case 1:
			warp "arug_cas01",256,35;
			end;
		case 2:
			warp "arug_cas01",186,26;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,83,232,0	script	LF-04#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 2-3:ma 2-4:")) {
		case 1:
			warp "arug_cas01",146,65;
			end;
		case 2:
			warp "arug_cas01",176,111;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,86,232,0	script	LF-05#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 3-1:ma 3-2:")) {
		case 1:
			warp "arug_cas01",94,126;
			end;
		case 2:
			warp "arug_cas01",126,126;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,89,232,0	script	LF-06#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ma 3-3:ma 3-4:")) {
		case 1:
			warp "arug_cas01",68,171;
			end;
		case 2:
			warp "arug_cas01",105,182;
			end;
		case 3:
			close;
		}
	}
	end;
}

arug_cas01,92,232,0	script	LF-07#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("I:")) {
		case 1:
			warp "arug_cas01",233,130;
			end;
		case 2:
			close;
		}
	}
	end;
}

arug_cas01,95,232,0	script	LF-08#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ϰ 1-1:ϰ 2-1:ϰ 3-1:")) {
		case 1:
			warp "arug_cas01",197,144;
			end;
		case 2:
			warp "arug_cas01",256,35;
			end;
		case 3:
			warp "arug_cas01",146,65;
			end;
		case 4:
			close;
		}
	}
	end;
}

arug_cas01,98,232,0	script	LF-09#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "пܭnʪ";
		switch(select("ϰ 1-2:ϰ 2-2:ϰ 3-3:")) {
		case 1:
			warp "arug_cas01",245,103;
			end;
		case 2:
			warp "arug_cas01",186,26;
			end;
		case 3:
			warp "arug_cas01",68,171;
			end;
		case 4:
			close;
		}
	}
	end;
}

arug_cas01,101,232,0	script	LF-10#arug_cas01	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "iHʨ쬰F|̪KQҧΦϰ,";
		mes "аݧAnʶ?";
		switch(select("ʨKQϰ:")) {
		case 1:
			warp "arug_cas01",121,357;
			end;
		case 2:
			close;
		}
	}
	end;
}

arug_cas01,72,176,0	script	ǧ#LF_ar01_1::LF_ar01_1	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "ʨ즳RݤԲa,";
		mes "аݧAnϥζ?";
		switch(select(":")) {
		case 1:
			warp "arug_cas01",67,193;
			end;
		case 2:
			close;
		}
	}
	end;
}

arug_cas01,103,186,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_2	111,{

arug_cas01,92,126,4	script	ǧ#LF_ar01_3::LF_ar01_2	111,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID) {
		mes "-Ka Ŷʨt-";
		mes "ʨ즳RݤԲa,";
		mes "аݧAnϥζ?";
		switch(select(":")) {
		case 1:
			warp "arug_cas01",67,193;
			end;
		case 2:
			close;
		}
	}
	end;

OnRecvCastleAr01:
	FlagEmblem GetCastleData("arug_cas01",1);
	end;
}

arug_cas01,127,126,4	duplicate(LF_ar01_2)	ǧ#LF_ar01_3	111
arug_cas01,150,102,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_4	111
arug_cas01,208,68,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_5	111
arug_cas01,249,52,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_6	111
arug_cas01,234,76,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_7	111
arug_cas01,249,76,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_8	111
arug_cas01,204,142,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_9	111
arug_cas01,183,244,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_10	111
arug_cas01,292,219,0	duplicate(LF_ar01_1)	ǧ#LF_ar01_11	111
arug_cas01,102,120,4	duplicate(LF_ar01_2)	ǧ#LF_ar01_12	722
arug_cas01,117,120,4	duplicate(LF_ar01_2)	ǧ#LF_ar01_13	722
arug_cas01,233,140,4	duplicate(LF_ar01_2)	ǧ#LF_ar01_14	722

// Guild Manager
arug_cas01,92,380,3	script	޲zH#aru01	55,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (.@GID == 0) {
		mes "[ ޲zH ]";
		mes "ڦbݧڪDH... i_Ḭ! lHARBa!";
		close;
	}
	if (getcharid(2) != .@GID || strcharinfo(0) != getguildmaster(.@GID)) {
		mes "[ ޲zH ]";
		mes "ާA̫¯٧,ڥu@NlHڪDH ^FF0000" + getguildmaster(.@GID) + "^000000 !";
		mes "@HA̦b̧r!";
		mes "֧oǵLzå̻a!";
		close;
	}
	mes "[ ޲zH ]";
	mes "w{,ڪDH ^FF0000" + getguildmaster(.@GID) + "^000000/pj...";
	mes "оާhJ,ڱNۦaA";
	next;
	switch(select("dݯKap:ӷ~oi:꨾m: / Ѷ ܮw¾:iJDHж")) {
	case 1:
		mes "[ ޲zH ]";
		mes "{bVAiKap";
		mes "{bӷ~oi׬O ^0000ff" + GetCastleData("arug_cas01",2) + " ";
		if (GetCastleData("arug_cas01",4) > 0) {
			mes "bLh@Ѥ,";
			mes "F " + GetCastleData("arug_cas01",4) + " ";
		}
		next;
		mes "[ ޲zH ]";
		mes "{bm׬O " + GetCastleData("arug_cas01",3) + " ";
		if (GetCastleData("arug_cas01",5) > 0) {
			mes "bLh@Ѥ,";
			mes "F " + GetCastleData("arug_cas01",5) + " ";
		}
		mes " ";
		mes "i";
		close;
	case 2:
		set .@Economy,GetCastleData("arug_cas01",2);
		if (.@Economy < 6) { set .@eco_invest,5000; }
		else if ((.@Economy >= 6) && (.@Economy <= 10)) { set .@eco_invest,10000; }
		else if ((.@Economy >= 11) && (.@Economy <= 15)) { set .@eco_invest,20000; }
		else if ((.@Economy >= 16) && (.@Economy <= 20)) { set .@eco_invest,35000; }
		else if ((.@Economy >= 21) && (.@Economy <= 25)) { set .@eco_invest,55000; }
		else if ((.@Economy >= 26) && (.@Economy <= 30)) { set .@eco_invest,80000; }
		else if ((.@Economy >= 31) && (.@Economy <= 35)) { set .@eco_invest,110000; }
		else if ((.@Economy >= 36) && (.@Economy <= 40)) { set .@eco_invest,145000; }
		else if ((.@Economy >= 41) && (.@Economy <= 45)) { set .@eco_invest,185000; }
		else if ((.@Economy >= 46) && (.@Economy <= 50)) { set .@eco_invest,230000; }
		else if ((.@Economy >= 51) && (.@Economy <= 55)) { set .@eco_invest,280000; }
		else if ((.@Economy >= 56) && (.@Economy <= 60)) { set .@eco_invest,335000; }
		else if ((.@Economy >= 61) && (.@Economy <= 65)) { set .@eco_invest,395000; }
		else if ((.@Economy >= 66) && (.@Economy <= 70)) { set .@eco_invest,460000; }
		else if ((.@Economy >= 71) && (.@Economy <= 75)) { set .@eco_invest,530000; }
		else if ((.@Economy >= 76) && (.@Economy <= 80)) { set .@eco_invest,605000; }
		else if ((.@Economy >= 81) && (.@Economy <= 85)) { set .@eco_invest,685000; }
		else if ((.@Economy >= 86) && (.@Economy <= 90)) { set .@eco_invest,770000; }
		else if ((.@Economy >= 91) && (.@Economy <= 95)) { set .@eco_invest,860000; }
		else if ((.@Economy >= 96) && (.@Economy <= 100)) { set .@eco_invest,955000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("arug_cas01",4)) {
			set .@eco_invest,.@eco_invest*4;
		}
		mes "[ ޲zH ]";
		mes "ӷ~oiת,bu|̥Ͳ~ƶq|W[,FH۷Q,ण";
		mes " ";
		mes "ӭ覡,@ѥu@,phI@I,@ѥiH⦸";
		mes " ";
		if (.@Economy == 100) {
			mes "[ ޲zH ]";
			mes "^FF0000ثemץHgO100F,AwgݭnA[JF^000000";
			close;
		}
		if (GetCastleData("arug_cas01",4) == 2) {
			mes "[ ޲zH ]";
			mes "^FF0000iOAwgbѤF⦸AF,^000000oi׻֤Wɴݵ۴IQlo";
			close;
		}
		if (GetCastleData("arug_cas01",4) == 0) {
			mes "[ ޲zH ]";
			mes "{bݭnꪺBO ^FF0000" + .@eco_invest + "^000000 ,аݧAn?";
		}
		else {
			mes "{bAwg@F...";
			mes "٭nA? ٻݭnl[^FF0000" + .@eco_invest + "^000000";
			mes "";
		}
		next;
		switch(select("ӷ~oi:")) {
		case 1:
			if (Zeny < .@eco_invest) {
				mes "[ ޲zH ]";
				mes "DH,ASiHӷ~oi";
				end;
			}
			set zeny,zeny-.@eco_invest;
			SetCastleData "arug_cas01",4,GetCastleData("arug_cas01",4)+1;
			mes "[ ޲zH ]";
			mes "QaF!";
			mes "ݵۧڭ̩n{,Ѫܵoi׷|W";
			close;
		case 2:
			mes "[ ޲zH ]";
			mes "ڱN̷ӧAhJh,OڪDH";
			mes "... ݭnӵ۫,ڭ̷|oܦn";
			close;
		}
	case 3:
		set .@Defence,GetCastleData("arug_cas01",3);
		if (.@Defence < 6) { set .@def_invest,10000; }
		else if ((.@Defence >= 6) && (.@Defence <= 10)) { set .@def_invest,20000; }
		else if ((.@Defence >= 11) && (.@Defence <= 15)) { set .@def_invest,40000; }
		else if ((.@Defence >= 16) && (.@Defence <= 20)) { set .@def_invest,70000; }
		else if ((.@Defence >= 21) && (.@Defence <= 25)) { set .@def_invest,110000; }
		else if ((.@Defence >= 26) && (.@Defence <= 30)) { set .@def_invest,160000; }
		else if ((.@Defence >= 31) && (.@Defence <= 35)) { set .@def_invest,220000; }
		else if ((.@Defence >= 36) && (.@Defence <= 40)) { set .@def_invest,290000; }
		else if ((.@Defence >= 41) && (.@Defence <= 45)) { set .@def_invest,370000; }
		else if ((.@Defence >= 46) && (.@Defence <= 50)) { set .@def_invest,460000; }
		else if ((.@Defence >= 51) && (.@Defence <= 55)) { set .@def_invest,560000; }
		else if ((.@Defence >= 56) && (.@Defence <= 60)) { set .@def_invest,670000; }
		else if ((.@Defence >= 61) && (.@Defence <= 65)) { set .@def_invest,790000; }
		else if ((.@Defence >= 66) && (.@Defence <= 70)) { set .@def_invest,920000; }
		else if ((.@Defence >= 71) && (.@Defence <= 75)) { set .@def_invest,1060000; }
		else if ((.@Defence >= 76) && (.@Defence <= 80)) { set .@def_invest,1210000; }
		else if ((.@Defence >= 81) && (.@Defence <= 85)) { set .@def_invest,1370000; }
		else if ((.@Defence >= 86) && (.@Defence <= 90)) { set .@def_invest,1540000; }
		else if ((.@Defence >= 91) && (.@Defence <= 95)) { set .@def_invest,1720000; }
		else if ((.@Defence >= 96) && (.@Defence <= 100)) { set .@def_invest,1910000; }
		//Quadruple the cost of investing if you've already invested once.
		if (GetCastleData("arug_cas01",5)) {
			set .@def_invest,.@def_invest*4;
		}
		mes "[ ޲zH ]";
		mes "m{ת,@HMRݪ@[׷|W[,Ҽ{쩹᪺Ԫ,o,";
		mes " ";
		mes "ӭ覡,@ѥu@,phI@I,@ѥiH⦸";
		mes " ";
		if (GetCastleData("arug_cas01",3) == 100) {
			mes "^FF0000ثemץHgO100F,AwgݭnA[JF^000000";
			close;
		}
		if (GetCastleData("arug_cas01",5) == 2) {
			mes "^FF0000iOAwgbѤF⦸AF,^000000oi׻֤Wɴݵ۴IQlo";
			close;
		}
		if (GetCastleData("arug_cas01",5) == 0) {
			mes "{bݭnꪺBO ^FF0000" + .@def_invest + "^000000 ,аݧAn?";
		}
		else {
			mes "{bAwg@F...";
			mes "٭nA? ٻݭnl[ ^FF0000" + .@def_invest + "^000000";
			mes "";
		}
		next;
		switch(select("꨾m:")) {
		case 1:
			if (Zeny < .@def_invest) {
				mes "[ ޲zH ]";
				mes "DH,ASiH꨾m";
				close;
			}
			set zeny,zeny-.@def_invest;
			SetCastleData "arug_cas01",5,GetCastleData("arug_cas01",5)+1;
			mes "[ ޲zH ]";
			mes "QaF!";
			mes "ݵۧڭ̩n{,Ѫܵoi׷|W";
			close;
		case 2:
			mes "[ ޲zH ]";
			mes "ڱN̷ӧAhJh,OڪDH";
			mes "... ݭnӵ۫,ڭ̷|oܦn";
			close;
		}
	case 4:
		if (GetCastleData("arug_cas01",9) == 1) {
			mes "[ ޲zH ]";
			mes "аݱznѶdԪAȤH?";
			next;
			switch(select("Ѷ:")) {
			case 1:
				cutin "kafra_01",2;
				mes "[ d ¾ ]";
				mes "ڰFƶ?pGڦƪ,бz̧,Aڤ@|?";
				next;
				switch(select("Ѷ:")) {
				case 1:
					mes "[ d ¾ ]";
					mes "~򬰱zAȯuOڳ̤j...";
					next;
					cutin "kafra_01",255;
					break;
				case 2:
					mes "[ d ¾ ]";
					mes "ڷ|VOԾĪzAȪ!";
					close;
				}
				break;
			case 2:
				mes "[ ޲zH ]";
				mes "DH,ڷQڭӭndU{bod¾,]owgܺɩүaڭ̪AȤF!";
				close;
			}
			disablenpc "d ¾#aru01";
			SetCastleData "arug_cas01",9,0;
			mes "[ ޲zH ]";
			mes "d¾wgѶF... LFW|۷Q,Υd¾W";
			close;
		}
		else {
			mes "[ ޲zH ]";
			mes "Md`qq,QnbKa̭,Υd¾?";
			mes "QnΪ,ݭn ^FF000010,000 ^000000";
			next;
			switch(select(":")) {
			case 1:
				if (getgdskilllv(.@GID,10001) == 0) {
					mes "[ ޲zH ]";
					mes "DH,p٨Sd`qqp,ҥH٤නΥd¾,pQnd`qñq,Ƿ|u|ޯत ^FF0000Mdԭq^000000ޯa";
					close;
				}
				if (Zeny < 10000) {
					mes "[ ޲zH ]";
					mes "DH,ASiHΥd¾";
					close;
				}
				set zeny,zeny-10000;
				enablenpc "d ¾#aru01";
				SetCastleData "arug_cas01",9,1;
				mes "[ ޲zH ]";
				mes "\Md`qñqF,zΤF@d¾!";
				next;
				cutin "kafra_01",2;
				mes "[ d ¾ ]";
				mes "zn?ڬO`qӪd¾!ڱN|ܺɩүazA!";
				next;
				cutin "kafra_01",255;
				mes "[ ޲zH ]";
				mes "Ϊd¾N^FF00001 Ӥ몺ɶ^000000bA,ɶFᥲsñq";
				close;
			case 2:
				mes "[ ޲zH ]";
				mes "ڤwgӧAhJF,L]nFW|۷Q,鶱Υd¾W";
				close;
			}
		}
	case 5:
		mes "[ ޲zH ]";
		mes "nڭ̥Ͳ~yn,uQ~ж?";
		mes "ӦaOFڭ̪DH,MݩAa...";
		mes "FA~,䥦HӤJ";
		next;
		mes "[ ޲zH ]";
		mes "|~,qЯSO`N,";
		mes "ҥHFڭ̤|oi,ЮXɶӦ~";
		next;
		switch(select("niJDHж:")) {
		case 1:
			mes "[ ޲zH ]";
			mes "ڱNAAȨ쯦KqD,иڨ,";
			mes "^ӪɭԫUKsYi";
			close2;
			warp "arug_cas01",250,363;
			end;
		case 2:
			mes "[ ޲zH ]";
			mes "Ͳ~@ѥuͲ@...";
			mes "pSYɦ,U@NiӤF";
			mes "ҥHFڭ̤u|oi,ɶqIɶh";
			close;
		}
	}

Onstop:
	stopnpctimer;
	end;

OnStartArena:
	set .@GID,getcharid(2);
	// Lower castle Economy
	set .@Economy,GetCastleData("arug_cas01",2) - 5;
	if (.@Economy < 0) set .@Economy, 0;
	SetCastleData "arug_cas01", 2, .@Economy;
	// Lower Castle Defence
	set .@Defence,GetCastleData("arug_cas01",3) - 5;
	if (.@Defence < 0) set .@Defence, 0;
	SetCastleData "arug_cas01", 3, .@Defence;
	// Set new owner
	SetCastleData "arug_cas01",1, .@GID;
	// Clear castle's data.
	for( set .@i, 4; .@i <= 9; set .@i, .@i+1 )
		SetCastleData "arug_cas01", .@i, 0;
	// Disable Kafra
	disablenpc "d ¾#aru01";

	set .msg,2;
	if (.msg == 1) {
		announce "Ka [" + GetCastleName("arug_cas01") + "] 'ǧ'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		donpcevent "Manager#aru01_02::Onstart";
	}
	else if (.msg == 2) {
		announce "Ka [" + GetCastleName("arug_cas01") + "] 'ǧ'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		mapannounce "arug_cas01","RݤwQ}aF",bc_map,"0x00FF00";
		if (agitcheck2()) {
			donpcevent "Manager#aru01_02::Onreset";
			initnpctimer;
		}
		else {
			donpcevent "Manager#aru01_02::Onreset";
			stopnpctimer;
		}
	}
	else if (.msg == 0) {
		announce "Ka [" + GetCastleName("arug_cas01") + "] 'ǧ'Q [" + getguildname(.@gid) + "] |ҦF",bc_all;
		donpcevent "Manager#aru01_02::Onreset";
		stopnpctimer;
		end;
	}
	MapRespawnGuildID "arug_cas01",GetCastleData("arug_cas01",1),2;
	GetCastleData "arug_cas01",0,"::OnRecvCastleAr01";
	end;

OnTimer10000:
	donpcevent "Manager#aru01_02::Onchange";
	mapannounce "arug_cas01","bUӾIMmu״_I wnF",bc_map,"0x00FF00";
	end;
}

// Guild Kafra
arug_cas01,31,362,3	script	d ¾#aru01	117,{
	cutin "kafra_01",2;
	set .@GID, GetCastleData("arug_cas01",1);
	if (getcharid(2) == .@GID && getgdskilllv(.@GID,10001)) {
		mes "[d ¾]";
		mes "w{ ^FF0000" + GetGuildName(.@GID) + "^000000 |,";
		mes "dԪA";
		mes "ûbU쨭䬰zAȪ";
		next;
		switch(select("ϥέܮwA:ϥΪŶʪA:ϥΤA:")) {
		case 1:
			if (basicskillcheck() && getskilllv(1) < 6) {
				mes "[d ¾]";
				mes "藍_";
				mes "QnϥέܮwAȪ,Ǫ̪򥻧ޯ൥ŭnF6ťHW";
			}
			else {
				openstorage;
			}
			break;
		case 2:
			mes "[d ¾]";
			mes "лXتaa";
			next;
			switch(select("Ի  -> 200 z:")) {
			case 1:
				if (Zeny < 200) {
					mes "[d ¾]";
					mes "zB,";
					mes "ЦAT{";
					close2;
					cutin "kafra_01",255;
					end;
				}
				set zeny,zeny-200;
				warp "rachel",115,125;
				end;
			case 2:
				cutin "kafra_01",255;
			}
			break;
		case 3:
			if (BaseClass != Job_Merchant) {
				mes "[d ¾]";
				mes "ܩp,";
				mes "OӤHMKK,NvMΪA";
			}
			else if (checkcart() == 1) {
				mes "[d ¾]";
				mes "zwgLF";
			}
			else {
				mes "[d ¾]";
				mes "ϥζOάO 800 ";
				mes "znϥζ?";
				next;
				switch(select("ϥ:")) {
				case 1:
					if (Zeny < 800) {
						mes "[d ¾]";
						mes "zB,";
						mes "ϥζOάO 800 ";
						close2;
						cutin "kafra_01",255;
						end;
					}
					set zeny,zeny-800;
					setcart;
					break;
				case 2:
					break;
				}
			}
			break;
		case 4:
			mes "[d ¾]";
			mes "ڭ̥dԪAȷ|ѧ󧹬AȩMY檺~Ⱥ޲z,UUȦw߫KQϥά̤jؼ";
			mes "P§AϥΥdԪA";
			close2;
			cutin "kafra_01",255;
			end;
		}
		close2;
		cutin "kafra_01",255;
		end;
	}
	else {
		mes "[d ¾]";
		mes "ڤwñqM^FF0000" + GetGuildName(.@GID) + "^000000|A,ШϥΧڭ̨䥦a誺d¾,pKBqШ";
		close2;
		cutin "kafra_01",255;
		end;
	}

OnRecvCastleAr01:
	if (GetCastleData("arug_cas01",1) == 0) {
		monster "arug_cas01",0,0,"x",1117,10;
		monster "arug_cas01",0,0,"dQ",1132,4;
		monster "arug_cas01",0,0,"`WMh",1219,3;
		monster "arug_cas01",0,0,"D",1205,1;
		monster "arug_cas01",0,0,"Ǯ",1216,10;
		monster "arug_cas01",0,0,"",1193,18;
		monster "arug_cas01",0,0,"j]",1269,9;
		monster "arug_cas01",0,0,"F}b",1276,12;
		monster "arug_cas01",0,0,"eH",1208,3;
		monster "arug_cas01",0,0,"RRk",1275,1;
		monster "arug_cas01",0,0,"{Mh",1268,2;
		monster "arug_cas01",0,0,"·t",1272,2;
		monster "arug_cas01",0,0,"u@",1270,4;
	}
	if (GetCastleData("arug_cas01",9) < 1) {
		disablenpc "d ¾#aru01";
	}
	end;
}

arug_cas01,259,371,0	script	#aru01_switch	111,{
	mes " ";
	mes "ӬYؤp˸m,аݧAnާ@?";
	next;
	switch(select("ާ@:")) {
	case 1:
		warp "arug_cas01",121,357;
		end;
	case 2:
		close;
	}
}

aru_gld,164,270,4	script	ǧ#flag_Ar01_1::Ar01_Flag	722,{
	set .@GID, GetCastleData("arug_cas01",1);
	if (.@GID == 0) {
		mes "[ cǨ а iO ]";
		mes "The Holy Kingdom of";
		mes "Arunafeltz declares that";
		mes "one has yet to claim lordship";
		mes "over this stronghold. The one";
		mes "that breaks the Emperium will";
		mes "be recognized as its new owner.";
		close;
	}
	else {
		if (getcharid(2) == .@GID) {
			mes "[ TGn ]";
			mes "i̭...";
			mes "An^A WAɨ?";
			next;
			switch(select("^쯵Ka:")) {
			case 1:
				set .@GID, GetCastleData("arug_cas01",1);
				if (getcharid(2) == .@GID) {
					warp "arug_cas01",67,193;
					end;
				}
				close;
			case 2:
				close;
			}
		}
		mes "[ cǨ а iO ]";
		mes " ";
		mes "1. ھڳo̪,cǨ аO";
		mes "o̳Q{w ^FF0000" + GetGuildName(.@GID) + "^000000|";
		mes "p";
		mes " ";
		mes "2. ^FF0000" + GetGuildName(.@GID) + "^000000 |DHO";
		mes "@@^FF0000" + GetGuildMaster(.@GID) + "^000000,L׬O";
		mes "@@oƱN";
		mes " ";
		mes "ЧA|_zC,ۤvWAa";
		close;
	}

OnRecvCastleAr01:
	FlagEmblem GetCastleData("arug_cas01",1);
	end;
}

aru_gld,142,235,4	duplicate(Ar01_Flag)	ǧ#flag_Ar01_2	722
aru_gld,164,245,5	duplicate(Ar01_Flag)	ǧ#flag_Ar01_3	722
aru_gld,182,255,5	duplicate(Ar01_Flag)	ǧ#flag_Ar01_4	722